import React from "react"
import { UserOutlined } from "@ant-design/icons"

import frontPage from "@/router/routes/frontPage"
import optionT from "@/router/routes/optionT"
import userL from "@/router/routes/userL"
function getItem(label, key, icon, children) {
  return {
    label,
    key,
    icon,
    children
  }
}
const _generateNavs = (router) => {
  if (!router.length) return false
  let flag = router.length > 1 ? true : false
  let newChildrenList = flag ? [] : {}
  router.forEach((item) => {
    if (item.meta.isMenu) {
      const { meta, path } = item
      if (flag) {
        newChildrenList.push({ label: meta.title, key: path })
      } else {
        newChildrenList = getItem(meta.title, path, meta.icon)
      }
    }
  })
  return newChildrenList
}
// 此处配置左侧菜单项
export default [
  _generateNavs(frontPage),
  _generateNavs(optionT),
  getItem("User", "1", <UserOutlined />, _generateNavs(userL))
]
